﻿
Imports System.Data
Imports VSModel
Imports Cls_Common

Partial Class Control_KhachSan_Detail
    Inherits System.Web.UI.UserControl
#Region "Sub and Function "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Not Request.QueryString("Id").ToString.Equals("0") Then
                hidID.Value = Request.QueryString("Id")
                ShowData()
            End If
        End If
    End Sub
    Protected Sub ShowData()
        Using data As New VSEntities
            Dim p As Hotel = (From q In data.Hotels Where q.Id = hidID.Value Select q).SingleOrDefault
            If Not p Is Nothing Then
                lblHotelCode.Text = IIf(IsNothing(p.HotelCode) = True, "", p.HotelCode)
                lblHotelname.Text = IIf(IsNothing(p.HotelName) = True, "", p.HotelName)

                If Not p.HotelTypeId Then
                    lblHoteltypeid.Text = (From k In data.HotelTypes Where k.HotelTypeId = p.HotelTypeId Select k.Title).FirstOrDefault
                End If


                lblAddress.Text = IIf(IsNothing(p.Address) = True, "", p.Address)
                lblBusinesslicence.Text = IIf(IsNothing(p.BusinessLicence) = True, "", p.BusinessLicence)
                lblNumberofroom.Text = IIf(IsNothing(p.NumberOfRoom) = True, "", p.NumberOfRoom)
                lblNumberofstaff.Text = IIf(IsNothing(p.NumberOfStaff) = True, "", p.NumberOfStaff)
                lblDirector.Text = IIf(IsNothing(p.Director) = True, "", p.Director)
                lblPhone.Text = IIf(IsNothing(p.Phone) = True, "", p.Phone)
                lblFax.Text = IIf(IsNothing(p.Fax) = True, "", p.Fax)
                lblEmail.Text = IIf(IsNothing(p.Email) = True, "", p.Email)
                lblWebsite.Text = IIf(IsNothing(p.WebSite) = True, "", p.WebSite)
                lblUserid.Text = IIf(IsNothing(p.UserId) = True, "", p.User.UserName & " - " & p.User.FullName)
            End If
        End Using
    End Sub
#End Region
End Class
